package controller.frontOffice;

import java.io.Serializable;
import java.util.List;

import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;

import org.primefaces.component.menuitem.MenuItem;
import org.primefaces.component.submenu.Submenu;
import org.primefaces.component.tabview.TabView;
import org.primefaces.model.DefaultMenuModel;
import org.primefaces.model.MenuModel;

import controller.backOffice.CategoryController;

import ejb.category.CategoryService;
import entities.Category;
import entities.Order;

//@Named
//@SessionScoped
@ManagedBean
@ViewScoped
public class MenuController implements Serializable{	

	private static final long serialVersionUID = 1L;
	private MenuModel model;

//	@EJB
//	private CategoryService categoryService;
	
	
	public MenuController() {
		model = new DefaultMenuModel();
		
		FacesContext ctx = FacesContext.getCurrentInstance();
		CategoryController cc = ctx.getApplication().evaluateExpressionGet(ctx, "#{categoryController}", CategoryController.class);		
		
		List<Category> categories = cc.getCategories();
		

		TabView tab = new TabView();

		for (Category toto : categories){
			MenuItem item = new MenuItem();
			item.setValue(toto.getTitle());	
			//item.setActionListener("#{categoryController.selectedCategory(toto)}");
			model.addMenuItem(item);
		}
		

		
		
//		MenuItem item = new MenuItem();
//		item.setValue("Dynamic Menuitem 1.1");
//		item.setUrl("#");
//		submenu.getChildren().add(item);
//
//		model.addSubmenu(submenu);

	}

	public MenuModel getModel() {
		return model;
	}	}

